home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 016 / herc.arc / GLINE.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-03-16  |  3.9 KB  |  179 lines

  1. ; C CALLABLE GRAPH LINE FUNCTION
  2. ; void gline(intx1, inty1, intx2, inty2);
  3.  
  4.         name    gline
  5.  
  6. extrn  _gmask:byte, _gaddr:word, _gmap:near
  7. public  _gline, _glin4
  8.  
  9. DGROUP  group   _DATA
  10.         assume  ds:DGROUP
  11.  
  12. _DATA   segment word    public  'DATA'
  13. gx1     dw      0
  14. gy1     dw      0
  15. temp1   db      0
  16. temp2   db      0
  17. _DATA   ends
  18.  
  19. _TEXT   segment byte    public  'CODE'
  20.         assume  cs:_TEXT
  21.  
  22. _gline  proc    near
  23.         push    bp
  24.         mov     bp, sp
  25.         push    es
  26.         push    di
  27.         push    si
  28.         call    glin2
  29.         pop     si
  30.         pop     di
  31.         pop     es
  32.         mov     sp, bp
  33.         pop     bp
  34.         ret
  35. _gline  endp
  36.  
  37. glin2   proc    near
  38.         push    [bp+6]
  39.         push    [bp+4]
  40.         call    _gmap
  41.         pop     gx1
  42.         pop     gy1
  43.         mov     cx, [bp+8]
  44.         mov     dx, [bp+10]
  45.  
  46. _glin4  proc    near
  47.         mov     ax,0b800h
  48.         mov     es,ax
  49.         cmp     gx1,cx
  50.         jnz     short hg654
  51.         call    vrtln
  52.         ret
  53.  
  54. hg654:  cmp     gy1,dx
  55.         jnz     short diagln
  56.         call    hrzln
  57.         ret
  58. diagln: mov     Byte Ptr temp2,01
  59.         sub     dx, gy1
  60.         jns     short hg675
  61.         neg     Byte Ptr temp2
  62.         neg     dx
  63. hg675:  mov     Byte Ptr temp1,01
  64.         sub     cx, gx1
  65.         jns     short hg689
  66.         neg     Byte Ptr temp1
  67.         neg     cx
  68. hg689:  mov     al, _gmask
  69.         mov     bx, _gaddr
  70.         mov     si,cx
  71.         cmp     cx,dx
  72.         jnb     short hg69a
  73.         mov     si,dx
  74. hg69a:  inc     si
  75.         mov     di,0
  76.         jmp     short hg6f3
  77. hg6a1:  cmp     di,0
  78.         jl      short hg6d0
  79.         sub     di,dx
  80.         cmp     Byte Ptr temp1,0
  81.         jl      short hg6bf
  82.         test    al,01
  83.         jz      short hg6ba
  84.         mov     al,80h
  85.         inc     bx
  86.         jmp     short hg6cb
  87. hg6ba:  shr     al,1
  88.         jmp     short hg6cb
  89. hg6bf:  test    al,80h
  90.         jz      short hg6c9
  91.         mov     al,01
  92.         dec     bx
  93.         jmp     short hg6cb
  94. hg6c9:  shl     al,1
  95. hg6cb:  cmp     di,0
  96.         jge     short hg6f3
  97. hg6d0:  add     di,cx
  98.         cmp     Byte Ptr temp2,0
  99.         jl      short hg6e8
  100.         add     bh,20h
  101.         jns     short hg6f3
  102.         and     bh,7fh
  103.         add     bx,5ah
  104.         jmp     short hg6f3
  105. hg6e8:  sub     bh,20h
  106.         jge     short hg6f3
  107.         and     bh,7fh
  108.         sub     bx,5ah
  109. hg6f3:  or      es:[bx],al
  110.         dec     si
  111.         jnz     short hg6a1
  112.         ret
  113. _glin4  endp
  114. glin2   endp
  115.  
  116. hrzln   proc    near
  117.         mov     al, _gmask
  118.         mov     bx, _gaddr
  119.         sub     cx, gx1
  120.         js      short hg5cd
  121.         inc     cx
  122.         jmp     short hg5b9
  123. hg5ad:  test    al,01
  124.         jz      short hg5b7
  125.         mov     al,80h
  126.         inc     bx
  127.         jmp     short hg5b9
  128. hg5b7:  shr     al,1
  129. hg5b9:  or      es:[bx],al
  130.         loop    hg5ad
  131.         ret
  132. hg5cd:  neg     cx
  133.         inc     cx
  134.         jmp     short hg5df
  135. hg5d3:  test    al,80h
  136.         jz      short hg5dd
  137.         mov     al,01
  138.         dec     bx
  139.         jmp     short hg5df
  140. hg5dd:  shl     al,1
  141. hg5df:  or      es:[bx],al
  142.         loop    hg5d3
  143.         ret
  144. hrzln   endp
  145.  
  146. vrtln   proc    near
  147.         mov     al, _gmask
  148.         mov     bx, _gaddr
  149.         sub     dx, gy1
  150.         js      short hg618
  151.         inc     dx
  152.         mov     cx,dx
  153.         jmp     short hg608
  154. hg5fd:  add     bh,20h
  155.         jns     short hg608
  156.         and     bh,7fh
  157.         add     bx,5ah
  158. hg608:  or      es:[bx],al
  159.         loop    hg5fd
  160.         ret
  161. hg618:  neg     dx
  162.         inc     dx
  163.         mov     cx,dx
  164.         jmp     short hg62b
  165. hg620:  sub     bh,20h
  166.         jns     short hg62b
  167.         and     bh,7fh
  168.         sub     bx,5ah
  169. hg62b:  or      es:[bx], al
  170.         loop    hg620
  171.         ret
  172.  
  173. vrtln   endp
  174.  
  175. _TEXT   ends
  176.         end
  177.  
  178.  
  179.